<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">
      <el-form-item label="年份" prop="roleName">
        <el-date-picker
          v-model="queryParams.roleName"
          type="year"
          placeholder="选择年">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button @click="handleAdd" size="mini">新增</el-button>
        <el-button @click="handleEdit" size="mini">编辑</el-button>
        <el-button @click="handleDelete" size="mini">删除</el-button>
        <el-button size="mini">复制</el-button>
      </el-col>
    </el-row>
    <el-table v-loading="loading" :data="list">
      <el-table-column label="年份" prop="roleName" />
      <el-table-column label="子表详情" prop="roleKey">
        <template slot-scope="scope">
          <el-button type="text" @click="view">查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="通用价格" name="first"></el-tab-pane>
      <el-tab-pane label="特殊价格" name="second"></el-tab-pane>
    </el-tabs>
    <template v-if="activeName==='first'">
      <el-table :data="listDetail1">
        <el-table-column type="index" :index="(index) => index + 1" label="序号" />
        <el-table-column label="物业类型" prop="q" />
        <el-table-column label="设施单价" prop="q" />
        <el-table-column label="费用类别" prop="q" />
        <el-table-column label="费用名称" prop="q" />
        <el-table-column label="税率" prop="q" />
        <el-table-column label="开票单位" prop="q" />
        <el-table-column label="计算方式" prop="q" />
      </el-table>
    </template>
    <template v-if="activeName==='second'">
      <el-table :data="listDetail2">
        <el-table-column type="index" :index="(index) => index + 1" label="序号" />
        <el-table-column label="租赁资源名称" prop="q" />
        <el-table-column label="单价" prop="q" />
        <el-table-column label="费用类别" prop="q" />
        <el-table-column label="费用名称" prop="q" />
        <el-table-column label="税率" prop="q" />
        <el-table-column label="开票单位" prop="q" />
        <el-table-column label="资源类型" prop="q" />
      </el-table>
    </template>
  </div>
</template>

<script>
import { listRole } from "@/api/system/role";

export default {
  data() {
    return {
      // 下拉数据
      options: [],
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        roleName: undefined
      },
      // tab
      activeName: 'first',
      // 通用价格列表
      listDetail1: [],
      // 特殊价格列表
      listDetail2: []
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 查看
    view() {

    },
    /** 查询角色列表 */
    getList() {
      this.loading = true;
      listRole(this.addDateRange(this.queryParams)).then(response => {
          this.list = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // tab改变
    handleClick() {
      
    },
    // 新增按钮
    handleAdd() {

    },
    // 编辑按钮
    handleEdit() {
      
    },
    // 删除按钮
    handleDelete() {
      this.$modal
        .confirm("确定要删除该记录吗？")
        .then(() => {
          
        })
    }
  }
};
</script>
